<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <!--    <link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">-->
    <link rel="stylesheet" th:href="@{/back/lib/layui-v2.6.3/css/layui.css}" media="all">
    <!--    <link rel="stylesheet" href="../css/public.css" media="all">-->
    <link rel="stylesheet" th:href="@{/back/css/public.css}" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">文章ID</label>
        <div class="layui-input-block">
            <input class="layui-input" name="articleId" placeholder="请输入文章ID" type="text"
                   lay-reqtext="文章ID不能为空" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">用户ID</label>
        <div class="layui-input-block">
            <input class="layui-input" name="userId" placeholder="请输入作者ID" type="text"
                   lay-reqtext="用户ID不能为空" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label ">父评论PID</label>
        <div class="layui-input-block">
            <input class="layui-input" name="pid" placeholder="请输入父评论PID(默认可为0)" type="text"
                   lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">评论的内容</label>
        <div class="layui-input-block">
            <input class="layui-input" name="plContent" placeholder="请输入评论的内容" type="text"
                   lay-reqtext="评论的内容不能为空" lay-verify="required">

        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">评论状态</label>
        <div class="layui-input-block">
            <input class="layui-input" name="status" placeholder="评论状态" type="text">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">评论用户登录的ip地址</label>
        <div class="layui-input-block">
            <input class="layui-input" name="ip" placeholder="ip地址" type="text">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-filter="saveBtn" lay-submit>确认保存</button>
        </div>
    </div>
</div>

<script th:src="@{/back/lib/layui-v2.6.3/layui.js}" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var index = layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            }, function () {
                $.ajax("/back-article-comment/save", {
                    data: data.field,
                    type: "POST",
                    dataType: "JSON",
                    success: function (result) {
                        console.log(data)
                        if (result.code == 0) {
                            // 关闭弹出层
                            layer.close(index);
                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex);
                            window.parent.location.reload();//父窗口刷新
                        }
                    },
                })
            });
            return false;
        });
    });

</script>
</body>
</html>